﻿
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
using IdentityUser = Volo.Abp.Identity.IdentityUser;

namespace EcoSystem
{
    /// <summary>
    ///  替换默认密码处理逻辑
    ///  context.Services.Replace(ServiceDescriptor.Singleton<IPasswordHasher<Volo.Abp.Identity.IdentityUser>, MyPasswordHasher>());
    /// </summary>
    [Dependency(ServiceLifetime.Singleton, ReplaceServices = true)]
    [ExposeServices(typeof(IPasswordHasher<IdentityUser>))]
    public class MyPasswordHasher : PasswordHasher<IdentityUser>, IPasswordHasher<IdentityUser>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public override string HashPassword(IdentityUser user, string password)
        {
            return base.HashPassword(user, password);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="hashedPassword"></param>
        /// <param name="providedPassword"></param>
        /// <returns></returns>
        public override PasswordVerificationResult VerifyHashedPassword(IdentityUser user, string hashedPassword, string providedPassword)
        {
            return base.VerifyHashedPassword(user, hashedPassword, providedPassword);
        }
    }
}
